package com.quickstart.web;

import com.quickstart.entity.TopicEntity;
import com.quickstart.topic.service.TopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author:wesley
 */
@Controller
@RequestMapping(value = "/web/topic")
public class TopicWebController {

    @Autowired
    private TopicService topicService;




    @RequestMapping(value = "/list")
    public String toList(HttpServletRequest request,String menuId){
        request.setAttribute("menuId",menuId);
        return "topic/list";
    }

    @RequestMapping(value = "/add")
    public String toAdd(){
        return "topic/add";
    }


    @RequestMapping(value = "/show")
    public String toShow(Integer id,HttpServletRequest request){
        TopicEntity topic = topicService.getTopicById(id);
        request.setAttribute("content",topic.getContent());
        return "topic/show";
    }


}
